package com.weido.test;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

public class ReetrantLockDemo {
    private Lock lock = new ReentrantLock();


    public void demo() {

        lock.lock();
        System.out.println("begin demo");
        demo2();
        lock.unlock();

    }
    public void demo2() {
        lock.lock();
        System.out.println("demo2");
        lock.unlock();
    }

    public static void main(String[] args) {
        ReetrantLockDemo demo = new ReetrantLockDemo();
        demo.demo();
    }
}
